////////////////////////////////////////////////
// File: AdvertisementController.java
// Description: Enter summary here after generation.
// Date: 2016-09-19 15:32:14
// Web: http://www.elanzhou.com/
////////////////////////////////////////////////
package com.mvc.controller;

import java.io.IOException;
import java.util.List;
import java.text.SimpleDateFormat;
import java.util.ArrayList;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.mvc.entity.Advertisement;
import com.mvc.entity.Business;
import com.mvc.entity.Meminfo;
import com.mvc.entity.News;
import com.mvc.service.AdvertisementService;
import com.mvc.service.BusinessService;
import com.mvc.service.GoodsService;
import com.mvc.service.HomeService;
import com.mvc.service.MarketService;
import com.mvc.service.MeminfoService;
import com.mvc.service.NewsService;
import com.mvc.service.SyscateService;
import com.mvc.service.SyschannelService;
import com.pub.MyJson;
import com.pub.Page;


@Controller
@RequestMapping("mobile")
public class mobileController {
	protected final transient Log logger = LogFactory
			.getLog(mobileController.class);
	@Autowired
	private MeminfoService meminfoService;
	@Autowired
	private HomeService homeService;
	@Autowired
	private NewsService newsService;
	@Autowired
	private MarketService marketService;
	@Autowired
	private GoodsService goodsService;
	@Autowired
	private SyschannelService syschannelService;
	@Autowired
	private BusinessService businessService;
	@Autowired
	private SyscateService syscateService;
	@Autowired
	private AdvertisementService  advertisementService;
	
	public mobileController() {
	}

	/* 列表 */
	@RequestMapping("Index.Action")
	public String Index(ModelMap modelMap) {
		/*
		 * String newson = ""; String marketon = ""; String goodson = ""; String
		 * businesson = ""; modelMap.put("newson", newson);
		 * modelMap.put("marketon", marketon); modelMap.put("goodson", goodson);
		 * modelMap.put("businesson", businesson);
		 */
		modelMap.put("homeSercice", homeService);
		return "/mobile/Index";

	}

	/* 底部供求列表 */
	@RequestMapping("GongqIndex.Action")
	public String GongqIndex(ModelMap modelMap) {
		modelMap.put("homeSercice", homeService);
		return "/mobile/GongqIndex";
	}

	/* 类目 */
	@RequestMapping("Cate.Action")
	public String Cate(ModelMap modelMap) {
		modelMap.put("homeSercice", homeService);
		return "/mobile/Cate";

	}

	/* 类目详细列表 */
	@RequestMapping("SyscateDetail.Action")
	public String SyscateDetail(ModelMap modelmap, HttpServletRequest request) {
		modelmap.put("homeSercice", homeService);
		String ID = request.getParameter("ID");
		com.mvc.entity.Syscate syscate = syscateService.getSyscate(ID);
		modelmap.put("syscate", syscate);
		modelmap.put("Catename", syscate.getCatename());
		return "/mobile/SyscateDetail";

	}

	/* 供需现货期货详情 */
	@RequestMapping("GoodsDetail.Action")
	public String GoodsDetail(HttpServletRequest request, HttpSession session,
			ModelMap modelMap, String pageNo, String Ajax) {
		/*
		 * String newson = ""; String marketon = ""; String goodson = "on";
		 * String businesson = ""; modelMap.put("newson", newson);
		 * modelMap.put("marketon", marketon); modelMap.put("goodson", goodson);
		 * modelMap.put("businesson", businesson); modelMap.put("homeSercice",
		 * homeService); Meminfo smeminfo = (Meminfo)
		 * session.getAttribute("SessionMem"); modelMap.put("smeminfo",
		 * smeminfo);
		 */
		String ID = request.getParameter("ID");
		com.mvc.entity.Goods goods = (com.mvc.entity.Goods) goodsService
				.getGoods(ID);
		modelMap.put("goods", goods);
		Meminfo meminfo = (Meminfo) meminfoService.getMeminfoByName(goods
				.getMembername());
		modelMap.put("meminfo", meminfo);
		return "/mobile/GoodsDetail";
	}

	/* 新闻详情 */
	@RequestMapping("NewsDetail.Action")
	public String NewsDetail(HttpServletRequest request, ModelMap modelMap) {
		/*String newson = "on";
		String marketon = "";
		String goodson = "";
		String businesson = "";
		modelMap.put("newson", newson);
		modelMap.put("marketon", marketon);
		modelMap.put("goodson", goodson);
		modelMap.put("businesson", businesson);
		modelMap.put("homeSercice", homeService);*/
		String ID = request.getParameter("ID");
		News news = (News) newsService.getNews(ID);
		modelMap.put("news", news);
		return "/mobile/NewsDetail";
	}

	/* 广告详情 */
	@RequestMapping("Ad.Action")
	public String Ad(HttpServletRequest request, ModelMap modelMap) {	
		
		String ID = request.getParameter("ID");
		Advertisement adt = (Advertisement) advertisementService.getAdvertisement(ID);
		modelMap.put("adt", adt);
		return "/mobile/Ad";
	}
	
	/* 新闻列表 */
	@RequestMapping("NewsList.Action")
	public String NewsList(HttpSession session, HttpServletRequest request,
			ModelMap modelMap, String pageNo, String Ajax) {

		String Syschannelname = request.getParameter("Syschannel");
		modelMap.put("Syschannelname", Syschannelname);		
		Page page = new Page();
		List list = new ArrayList();
		if (Syschannelname != null) {
			page.setPageNox(pageNo);
			page.setPageSize(15);
			page.setVal(",'Syschannel':'" + Syschannelname + "'");
			String hql = "select a from News a where a.Syschannel='"
					+ Syschannelname + "' order by a.ID desc";
			list = newsService.getNewsList(hql, page);
			String counthql = "select count(*) from  News a where a.Syschannel='"
					+ Syschannelname + "'";
			page.setPageCount(newsService.getCount(counthql, page));
		} else {
			page.setPageNox(pageNo);
			page.setPageSize(15);
			String hql = "select a from News a  order by a.ID desc";
			list = newsService.getNewsList(hql, page);
			String counthql = "select count(*) from  News a";
			page.setPageCount(newsService.getCount(counthql, page));
		}
		modelMap.put("page", page);
		modelMap.put("list", list);		
		if (Ajax != null && Ajax.equals("Ajax")) {
			return "/mobile/NewsList";
		} else {
			return "/mobile/News";
		}
	}

	/* 类目的新闻列表 */
	@RequestMapping("CateNewsList.Action")
	public String CateNewsList(HttpSession session, HttpServletRequest request,
			ModelMap modelMap, String pageNo, String Ajax) {

		String Catename = request.getParameter("Catename");
		modelMap.put("Catename", Catename);	
		Page page = new Page();
		List list = new ArrayList();
		if (Catename != null) {
			page.setPageNox(pageNo);
			page.setPageSize(15);
			page.setVal(",'Catename':'" + Catename + "'");
			String hql = "select a from News a where a.Catename='" + Catename
					+ "' order by a.ID desc";
			list = newsService.getNewsList(hql, page);
			String counthql = "select count(*) from  News a where a.Catename='"
					+ Catename + "'";
			page.setPageCount(newsService.getCount(counthql, page));
		} else {
			page.setPageNox(pageNo);
			page.setPageSize(15);
			String hql = "select a from News a  order by a.ID desc";
			list = newsService.getNewsList(hql, page);
			String counthql = "select count(*) from  News a";
			page.setPageCount(newsService.getCount(counthql, page));
		}
		modelMap.put("page", page);
		modelMap.put("list", list);		
		if (Ajax != null && Ajax.equals("Ajax")) {
			return "/mobile/CateNewsList";
		} else {
			return "/mobile/CateNews";
		}

	}

	/* 所有新闻栏目的列表 */
	@RequestMapping("Xinw.Action")
	public String Xinw(ModelMap modelMap) {
		modelMap.put("homeSercice", homeService);
		return "/mobile/Xinw";
	}

	/* 行情列表 */
	/*行情总页面*/
	@RequestMapping("Market.Action")
	public String Market(HttpSession session, HttpServletRequest request,
			ModelMap modelMap, String pageNo, String Ajax) {		
		modelMap.put("homeSercice", homeService);		
			return "/mobile/Market";
	}
	/*产地价翻页页码*/
	@RequestMapping("CdpriceList.Action")
	public String CdpriceList(HttpSession session, HttpServletRequest request,
			ModelMap modelMap, String pageNo, String Ajax) {
		
		Page page = new Page();
		List list = new ArrayList();

		page.setPageNox(pageNo);
		page.setPageSize(15);

		String hql = "select a from Market a  order by a.ID desc";
		list = marketService.getMarketList(hql, page);
		String counthql = "select count(*) from  Market a";
		page.setPageCount(marketService.getCount(counthql, page));

		modelMap.put("page", page);
		modelMap.put("list", list);
		if (Ajax != null && Ajax.equals("Ajax")) {
			return "/mobile/CdpriceList";
		} else {
			return "/mobile/Cdprice";
		}

	}
	
	/*市场价翻页页码*/
	@RequestMapping("ScpriceList.Action")
	public String ScpriceList(HttpSession session, HttpServletRequest request,
			ModelMap modelMap, String pageNo, String Ajax) {
		
		Page page = new Page();
		List list = new ArrayList();

		page.setPageNox(pageNo);
		page.setPageSize(15);

		String hql = "select a from Market a  order by a.ID desc";
		list = marketService.getMarketList(hql, page);
		String counthql = "select count(*) from  Market a";
		page.setPageCount(marketService.getCount(counthql, page));

		modelMap.put("page", page);
		modelMap.put("list", list);
		if (Ajax != null && Ajax.equals("Ajax")) {
			return "/mobile/ScpriceList";
		} else {
			return "/mobile/Scprice";
		}

	}
	/*市场价翻页页码*/
	@RequestMapping("PlpriceList.Action")
	public String PlpriceList(HttpSession session, HttpServletRequest request,
			ModelMap modelMap, String pageNo, String Ajax) {
		
		Page page = new Page();
		List list = new ArrayList();

		page.setPageNox(pageNo);
		page.setPageSize(15);

		String hql = "select a from Market a  order by a.ID desc";
		list = marketService.getMarketList(hql, page);
		String counthql = "select count(*) from  Market a";
		page.setPageCount(marketService.getCount(counthql, page));

		modelMap.put("page", page);
		modelMap.put("list", list);
		if (Ajax != null && Ajax.equals("Ajax")) {
			return "/mobile/PlpriceList";
		} else {
			return "/mobile/Plprice";
		}
			
		}
	

	/*供/求/现货/期货的列表*/
	@RequestMapping("GongqList.Action")
	public String GongqList(HttpSession session, HttpServletRequest request,
			ModelMap modelMap, String pageNo, String Ajax) {
		String Goodstype = request.getParameter("Goodstype");
		modelMap.put("Goodstype", Goodstype);		
		Page page = new Page();
		List list = new ArrayList();
		if (Goodstype != null) {
			page.setPageNox(pageNo);
			page.setPageSize(15);
			page.setVal(",'Goodstype':'" + Goodstype + "'");
			String hql = "select a from Goods a where a.Status='已审核' and a.Goodstype='"+Goodstype+"' order by a.ID desc";
			list = goodsService.getGoodsList(hql, page);
			String counthql = "select count(*) from  Goods a where a.Status='已审核' and a.Goodstype='"+Goodstype+"'";
			page.setPageCount(goodsService.getCount(counthql, page));

		} else {
			page.setPageNox(pageNo);
			page.setPageSize(15);
			String hql = "select a from Goods a  order by a.ID desc";
			list = goodsService.getGoodsList(hql, page);
			String counthql = "select count(*) from  Goods a";
			page.setPageCount(goodsService.getCount(counthql, page));
		}
		modelMap.put("page", page);
		modelMap.put("list", list);	
		if (Ajax != null && Ajax.equals("Ajax")) {
			return "/mobile/GongqList";
		} else {
			return "/mobile/Gongq";
		}
	}
	
	/*类目的供/求/现货/期货的列表*/
	@RequestMapping("CateGongqList.Action")
	public String CateGongqList(HttpSession session, HttpServletRequest request,
			ModelMap modelMap, String pageNo, String Ajax) {
		String Catename = request.getParameter("Catename");
		String Goodstype=request.getParameter("Goodstype");
		modelMap.put("Catename", Catename);
		modelMap.put("Goodstype", Goodstype);
		Page page = new Page();
		List list = new ArrayList();
		if (Catename != null) {
			page.setPageNox(pageNo);
			page.setPageSize(15);
			page.setVal(",'Catename':'" + Catename + "','Goodstype':'" + Goodstype + "'");
			String hql = "select a from Goods a where a.Status='已审核' and a.Catename='"+Catename+"' and a.Goodstype='"+Goodstype+"' order by a.ID desc";
			list = goodsService.getGoodsList(hql, page);
			String counthql = "select count(*) from  Goods a where a.Status='已审核' and a.Catename='"+Catename+"' and a.Goodstype='"+Goodstype+"'";
			page.setPageCount(goodsService.getCount(counthql, page));

		} else {
			page.setPageNox(pageNo);
			page.setPageSize(15);
			String hql = "select a from Goods a  order by a.ID desc";
			list = goodsService.getGoodsList(hql, page);
			String counthql = "select count(*) from  Goods a";
			page.setPageCount(goodsService.getCount(counthql, page));
		}
		modelMap.put("page", page);
		modelMap.put("list", list);	
		if (Ajax != null && Ajax.equals("Ajax")) {
			return "/mobile/CateGongqList";
		} else {
			return "/mobile/CateGongq";
		}
	}
	
	

	// /以下暂未用

	/* 管理员欢迎页面 */
	@RequestMapping("Welcome.do")
	public String Welcome(HttpSession session, ModelMap modelMap) {
		Meminfo smeminfo = (Meminfo) session.getAttribute("SessionMem");
		modelMap.put("smeminfo", smeminfo);
		return "/mobile/Welcome";

	}

	/* 登录页面 */
	@RequestMapping("Login.Action")
	public String Login() {
		return "/mobile/Login";

	}

	/* 退出 */
	@RequestMapping("Logout.Action")
	public void Logout(HttpSession session, ModelMap modelMap,
			HttpServletResponse response) {

		session.invalidate();
		String str = "{\"statusCode\":200,\"message\":\"退出成功\",\"callbackType\":\"forward\",\"forwardUrl\":\"/Login.Action\"}";
		try {
			response.getWriter().print(str);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	/* 会员页面 */
	@RequestMapping("Member.do")
	public String Member(HttpSession session, ModelMap modelMap) {
		Meminfo smeminfo = (Meminfo) session.getAttribute("SessionMem");
		modelMap.put("smeminfo", smeminfo);
		return "/mobile/Member";

	}

	/* 银行 */
	@RequestMapping("Bank.do")
	public String Bank(HttpSession session, ModelMap modelMap) {
		Meminfo smeminfo = (Meminfo) session.getAttribute("SessionMem");
		modelMap.put("smeminfo", smeminfo);
		return "/mobile/Bank";

	}

	/* 登录验证 */
	@RequestMapping("CheckUser.Action")
	public void CheckUser(HttpSession session, String username,
			String password, String verify, HttpServletResponse response) {
		String myverify = (String) session.getAttribute("validateCode");
		myverify = myverify.toLowerCase();
		verify = verify.toLowerCase();
		if (verify.equals(myverify)) {
			Meminfo user = (Meminfo) meminfoService.getMeminfoByName(username);
			if (user != null) {
				if (user.getMempass().equals(password)) {
					if (user.getStatus().equals("未审核")) {
						try {
							MyJson myjson = new MyJson();
							myjson.setStatusCode(300);
							myjson.setMessage("登录失败,请等待审核！");
							myjson.setCallbackType("forward");
							myjson.setForwardUrl("#");
							response.getWriter().print(myjson.getJson());
						} catch (IOException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
							// log.error(e.getMessage());
						}
					} else {
						session.setAttribute("SessionMem", user);
						try {
							MyJson myjson = new MyJson();
							myjson.setStatusCode(200);
							myjson.setMessage("登陆成功");
							myjson.setCallbackType("forward");
							switch (user.getRolename()) {
							case ("管理员"):
								myjson.setForwardUrl("/Welcome.do");
								break;
							case ("银行"):
								myjson.setForwardUrl("/Bank.do");
								break;
							case ("员工"):
								myjson.setForwardUrl("/Employee.do");
								break;
							default:
								myjson.setForwardUrl("/Member.do");
								break;
							}
							response.getWriter().print(myjson.getJson());
						} catch (IOException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
							// log.error(e.getMessage());
						}
					}
				} else {
					try {
						MyJson myjson = new MyJson();
						myjson.setStatusCode(300);
						myjson.setMessage("登录失败");
						myjson.setCallbackType("forward");
						myjson.setForwardUrl("#");
						response.getWriter().print(myjson.getJson());
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
						// log.error(e.getMessage());
					}
				}
			} else {
				try {
					MyJson myjson = new MyJson();
					myjson.setStatusCode(300);
					myjson.setMessage("登录失败,用户名不存在");
					myjson.setCallbackType("forward");
					myjson.setForwardUrl("#");
					response.getWriter().print(myjson.getJson());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
					// log.error(e.getMessage());
				}
			}
		} else {
			try {
				MyJson myjson = new MyJson();
				myjson.setStatusCode(300);
				myjson.setMessage("验证码错误，请刷新验证码！");
				myjson.setCallbackType("forward");
				myjson.setForwardUrl("#");
				response.getWriter().print(myjson.getJson());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				// log.error(e.getMessage());
			}
		}
	}

	/* 注册 */
	@RequestMapping("Regist.Action")
	public String Regist() {
		return "/mobile/Regist";

	}

	/* 注册保存 */
	@RequestMapping("RegistOk.Action")
	public void RegistOk(HttpServletResponse response,
			HttpServletRequest request, ModelMap modelMap, HttpSession session) {
		try {

			Meminfo meminfo = new Meminfo();
			boolean tag = true;
			String Msg = "信息保存成功";

			if (tag) {

				String FieldMemname = (String) request.getParameter("Memname");

				if (((FieldMemname != null) & (!FieldMemname.trim().equals("")))) {
					FieldMemname = FieldMemname.trim();
					meminfo.setMemname(FieldMemname);
					Meminfo mi = meminfoService.getMeminfoByName(FieldMemname);

					if (mi == null) {

					} else {
						tag = false;
						Msg = "会员名称已存在！";
					}
				}
			} else {
				tag = false;
				Msg = "会员名称不能为空！";
			}

			if (tag) {

				String FieldMempass = (String) request.getParameter("Mempass");

				if (((FieldMempass != null) & (!FieldMempass.trim().equals("")))) {
					FieldMempass = FieldMempass.trim();
					meminfo.setMempass(FieldMempass);

				} else {
					tag = false;
					Msg = "会员密码不能为空！";
				}
			}

			if (tag) {

				String FieldRolename = (String) request
						.getParameter("Rolename");

				if (((FieldRolename != null) & (!FieldRolename.trim()
						.equals("")))) {
					FieldRolename = FieldRolename.trim();
					meminfo.setRolename(FieldRolename);

				} else {
					tag = false;
					Msg = "角色名称不能为空！";
				}
			}

			if (tag) {

				String FieldCompanyname = (String) request
						.getParameter("Companyname");

				if (((FieldCompanyname != null) & (!FieldCompanyname.trim()
						.equals("")))) {
					FieldCompanyname = FieldCompanyname.trim();
					meminfo.setCompanyname(FieldCompanyname);

				} else {
					tag = false;
					Msg = "公司名称不能为空！";
				}
			}

			if (tag) {

				String FieldPrivince = (String) request
						.getParameter("Privince");

				if (((FieldPrivince != null) & (!FieldPrivince.trim()
						.equals("")))) {
					FieldPrivince = FieldPrivince.trim();
					meminfo.setPrivince(FieldPrivince);

				} else {
					tag = false;
					Msg = "所在省份不能为空！";
				}
			}

			if (tag) {

				String FieldCity = (String) request.getParameter("City");

				if (((FieldCity != null) & (!FieldCity.trim().equals("")))) {
					FieldCity = FieldCity.trim();
					meminfo.setCity(FieldCity);

				} else {
					tag = false;
					Msg = "所在市州不能为空！";
				}
			}

			if (tag) {

				String FieldDistrict = (String) request
						.getParameter("District");

				if (((FieldDistrict != null) & (!FieldDistrict.trim()
						.equals("")))) {
					FieldDistrict = FieldDistrict.trim();
					meminfo.setDistrict(FieldDistrict);

				} else {
					tag = false;
					Msg = "所在县区不能为空！";
				}
			}

			if (tag) {

				String FieldContactman = (String) request
						.getParameter("Contactman");

				if (((FieldContactman != null) & (!FieldContactman.trim()
						.equals("")))) {
					FieldContactman = FieldContactman.trim();
					meminfo.setContactman(FieldContactman);

				} else {
					tag = false;
					Msg = "联系人不能为空！";
				}
			}

			if (tag) {

				String FieldContacttel = (String) request
						.getParameter("Contacttel");

				if (((FieldContacttel != null) & (!FieldContacttel.trim()
						.equals("")))) {
					FieldContacttel = FieldContacttel.trim();
					meminfo.setContacttel(FieldContacttel);

				} else {
					tag = false;
					Msg = "联系电话不能为空！";
				}
			}

			if (tag) {

				String FieldAddress = (String) request.getParameter("Address");

				if (((FieldAddress != null) & (!FieldAddress.trim().equals("")))) {
					FieldAddress = FieldAddress.trim();
					meminfo.setAddress(FieldAddress);

				} else {
					tag = false;
					Msg = "地址不能为空！";
				}
			}

			meminfo.setStatus("未审核");

			MyJson mj = new MyJson();
			if (tag) {
				meminfoService.Save(meminfo);
				mj.setStatusCode(200);
			} else {
				mj.setStatusCode(300);
			}
			mj.setMessage(Msg);
			mj.setForwardUrl("/Login.Action");
			mj.setCallbackType("forward");
			String str = mj.getJson();
			response.getWriter().print(str);
		} catch (Exception e) {
			logger.error(e.getMessage());
			e.printStackTrace();
		}
	}

	@RequestMapping("Syscate.Action")
	public String Syscate(ModelMap modelmap) {
		modelmap.put("homeSercice", homeService);
		return "/mobile/Syscate";

	}

	@RequestMapping("Scnews.Action")
	public String Scnews(HttpSession session, HttpServletRequest request,
			ModelMap modelMap, String pageNo, String Ajax) {
		modelMap.put("homeSercice", homeService);
		String CID = request.getParameter("CID");
		com.mvc.entity.Syscate syscate = syscateService.getSyscate(CID);
		modelMap.put("syscate", syscate);
		Page page = new Page();
		List list = new ArrayList();
		page.setPageNox(pageNo);
		page.setPageSize(15);
		page.setVal(",\"CID\":" + CID);
		String hql = "select a from News a where a.Catename='"
				+ syscate.getCatename() + "' order by a.ID desc";
		list = newsService.getNewsList(hql, page);
		String counthql = "select count(*) from  News a where a.Catename='"
				+ syscate.getCatename() + "'";
		page.setPageCount(newsService.getCount(counthql, page));
		modelMap.put("page", page);
		modelMap.put("list", list);
		if (Ajax != null && Ajax.equals("Ajax")) {
			return "/mobile/ScNewsList";
		} else {
			return "/mobile/ScNews";
		}

	}

	/* 列表 */
	@RequestMapping("RegistNameCheck.Action")
	public void RegistNameCheck(HttpServletRequest request,
			HttpServletResponse response) {
		// System.out.println("==============="+request.getParameter("Memname")+"==============");
		String Memname = request.getParameter("Memname");
		Meminfo mi = meminfoService.getMeminfoByName(Memname);
		try {
			if (mi == null) {
				response.getWriter().print("{\"valid\":true}");
			} else {
				response.getWriter().print("{\"valid\":false}");
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	@RequestMapping("BusinessDetail.Action")
	public String BusinessDetail(HttpServletRequest request,
			HttpSession session, ModelMap modelMap, String pageNo, String Ajax) {
		String newson = "";
		String marketon = "";
		String goodson = "";
		String businesson = "on";
		modelMap.put("newson", newson);
		modelMap.put("marketon", marketon);
		modelMap.put("goodson", goodson);
		modelMap.put("businesson", businesson);

		modelMap.put("homeSercice", homeService);
		Meminfo smeminfo = (Meminfo) session.getAttribute("SessionMem");
		modelMap.put("smeminfo", smeminfo);
		String ID = request.getParameter("ID");
		Business business = (Business) businessService.getBusiness(ID);
		modelMap.put("business", business);
		return "/mobile/BusinessDetail";

	}

	@RequestMapping("Business.Action")
	public String Business(HttpSession session, ModelMap modelMap,
			String pageNo, String Ajax) {
		String newson = "";
		String marketon = "";
		String goodson = "";
		String businesson = "on";
		modelMap.put("newson", newson);
		modelMap.put("marketon", marketon);
		modelMap.put("goodson", goodson);
		modelMap.put("businesson", businesson);

		modelMap.put("homeSercice", homeService);
		Meminfo smeminfo = (Meminfo) session.getAttribute("SessionMem");
		modelMap.put("smeminfo", smeminfo);
		Page page = new Page();
		page.setPageNox(pageNo);
		page.setPageSize(15);
		String hql = "select a from Business a order by a.ID desc";
		List list = businessService.getBusinessList(hql, page);
		String counthql = "select count(*) from Business a";
		page.setPageCount(businessService.getCount(counthql, page));
		modelMap.put("page", page);
		modelMap.put("list", list);
		if (Ajax != null && Ajax.equals("Ajax")) {
			return "/mobile/BusinessList";
		} else {
			return "/mobile/Business";
		}

	}

	// 行情
	@RequestMapping("ScGoods.Action")
	public String ScGoods(HttpSession session, HttpServletRequest request,
			ModelMap modelMap, String pageNo, String Ajax) {
		modelMap.put("homeSercice", homeService);
		String Goodstype = request.getParameter("Goodstype");
		modelMap.put("GoodsType", Goodstype);
		String CID = request.getParameter("CID");
		com.mvc.entity.Syscate syscate = syscateService.getSyscate(CID);
		modelMap.put("syscate", syscate);

		Page page = new Page();
		List list = new ArrayList();
		if (Goodstype == null) {
			page.setPageNox(pageNo);
			page.setPageSize(15);
			page.setVal("");
			String hql = "select a from Goods a where a.Status<>'未审核' and a.Catename='"
					+ syscate.getCatename() + "' order by a.ID desc";
			list = goodsService.getGoodsList(hql, page);
			String counthql = "select count(*) from  Goods a where a.Status<>'未审核' and a.Catename='"
					+ syscate.getCatename() + "'";
			page.setPageCount(goodsService.getCount(counthql, page));
		} else {
			page.setPageNox(pageNo);
			page.setPageSize(15);
			page.setVal(",'CID':" + syscate.getId() + ",'Goodstype':'"
					+ Goodstype + "'");
			String hql = "select a from Goods a where a.Goodstype='"
					+ Goodstype + "' and  a.Status<>'未审核' and a.Catename='"
					+ syscate.getCatename() + "'   order by a.ID desc";
			list = goodsService.getGoodsList(hql, page);
			String counthql = "select count(*) from  Goods a where a.Goodstype='"
					+ Goodstype
					+ "'  and a.Status<>'未审核' and a.Catename='"
					+ syscate.getCatename() + "'";
			page.setPageCount(goodsService.getCount(counthql, page));
			modelMap.put("Goodstype", Goodstype);
		}

		modelMap.put("page", page);
		modelMap.put("list", list);
		if (Ajax != null && Ajax.equals("Ajax")) {
			return "/mobile/ScGoodsList";
		} else {
			return "/mobile/ScGoods";
		}

	}

}
